package cn.yyt.yytravel.guide.service.impl;

import cn.yyt.yytravel.guide.mapper.ReviewMapper;
import cn.yyt.yytravel.guide.pojo.dto.GuideInfo;
import cn.yyt.yytravel.guide.pojo.entity.GuideReviews;
import cn.yyt.yytravel.guide.pojo.vo.GuideReviewsVO;
import cn.yyt.yytravel.guide.service.ReviewService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class ReviewServiceImpl implements ReviewService {
    @Autowired
    ReviewMapper reviewMapper;
    
    @Override
    public void insertReviews(GuideInfo guideInfo) {
        GuideReviews guideReviews = new GuideReviews();
        BeanUtils.copyProperties(guideInfo,guideReviews);
        guideReviews.setReviewTime(new Date());
        reviewMapper.insertReview(guideReviews);
    }

    @Override
    public GuideReviewsVO selectReviews(Long touristId, Long guideId) {
        GuideReviewsVO guideReviewsVO = reviewMapper.selectReviews(touristId,guideId);
        return guideReviewsVO;
    }
}
